package org.example.blog.Mapper;

import org.apache.ibatis.annotations.*;
import org.example.blog.pojo.*;
import org.springframework.web.bind.annotation.PutMapping;

import java.util.List;

@Mapper
public interface IndexMapper {
    // 查询快速导航数据
    @Select("select * from websites")
    List<FastNavigation> list();

    // 增加快速导航数据
    @Insert("INSERT INTO websites(name, detail,icon,url)" +
            "values (#{name},#{detail},#{icon},#{url})")
    void insert(FastNavigation fastNavigation);

    // 删除导航栏
    @Delete("delete from websites where id = #{id}")
    void deleteById(Integer id);

    //更新数据
    void update(FastNavigation fastNavigation);

    // 上传图片
    @Insert("insert into slideshow(site)" +
            "values (#{site})")
    void add1(String path);

    // 查询照片
    @Select("select * from slideshow")
    List<Slideshow> list1();

    //删除照片
    @Delete("delete from slideshow where id = #{id}")
    void deleteById1(Integer id);

    //更新图片
    @Update("update slideshow set site = #{site} where id=#{id} ")
    void update1(Slideshow slideshow);

    //分页查找首页文章
    List<ArticleMs> list2();

    //添加首页文章
    @Insert("insert into ms_article(title, subtitle, create_time, content, image_url)  " +
            "values (#{title},#{subtitle},#{createTime},#{content},#{imageUrl})")
    void addArticle(ArticleMs articleMs);

    //添加文章的标签
    void addTag(List<Tag> tags, Integer articleId);

    Integer getArticleId();

    // 删除首页文章和首页文章_标签的联立表
    @Delete("delete from ms_article where id = #{id}")
    void deleteArticleById(Integer id);
    @Delete("delete from article_tag where article_id = #{id}")
    void deleteTagById(Integer id);

    //修改首页文章内容
    void update2(ArticleMs articleMs);
}
